package com.beiing.tianshuai.tianshuai.mine.presenter;

import com.beiing.tianshuai.tianshuai.base.BasePresenter;
import com.beiing.tianshuai.tianshuai.entity.UpdatePersonalInfoBean;
import com.beiing.tianshuai.tianshuai.mine.model.PersonalInfoModel;
import com.beiing.tianshuai.tianshuai.mine.view.PersonalInfoViewImpl;

import java.io.File;

/**
 * Created by Jinni on 2017/7/26 0026.
 */

public class PersonalInfoPresenter extends BasePresenter implements PersonalInfoPresenterImpl, PersonalInfoModel.OnRequestListener{

    private PersonalInfoViewImpl mView;
    private PersonalInfoModel mModel;

    public PersonalInfoPresenter(PersonalInfoViewImpl view) {
        mView = view;
        mModel = new PersonalInfoModel(this);
    }

    @Override
    public void getEditPersonalInfoResult(String uid, String name, String sex, String tel, String unit, String sign, String email) {
        mView.showProgress();
        mModel.getEditPersonalInfoResult(uid, name, sex, tel, unit, sign, email);
    }

    @Override
    public void getUpdateAvatarResult(String uid, File avatar) {
        mView.showProgress();
        mModel.getUpdateAvatarResult(uid, avatar);
    }

    @Override
    public void onSuccess(UpdatePersonalInfoBean bean) {
        mView.hideProgress();
        mView.onRequestSuccess(bean);
    }

    @Override
    public void updateAvatarSuccess(UpdatePersonalInfoBean bean) {
        mView.hideProgress();
        mView.UpdateAvatar(bean);
    }

    @Override
    public void onError(Throwable throwable) {
        mView.hideProgress();
        mView.onRequestFailed(throwable);
    }
}
